﻿using Consul;
using Microsoft.AspNetCore.Http;
using Microsoft.AspNetCore.Mvc;

namespace Equipment.API.Controllers
{
    /// <summary>
    /// 测试控制器
    /// </summary>
    [Route("api/[controller]/[action]")]
    [ApiController]
    public class ServicesController : ControllerBase
    {
        private readonly IConsulClient _consulClient;

        public ServicesController(IConsulClient consulClient)
        {
            _consulClient = consulClient;
        }

        [HttpGet]
        public async Task<IActionResult> GetServices()
        {
            var services = await _consulClient.Agent.Services();
            return Ok(services.Response);
        }


        /// <summary>
        /// 测试控制器
        /// </summary>
        /// <returns></returns>
        [HttpGet]
        public IActionResult Get()
        {
            return Ok(new { Message = "Hello from SampleController!" });
        }
    }
}
